package com.example.uploadminio;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class AutoStartChecker {

    private static final String REG_PATH = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
     private static final String APP_NAME = "UploadMinioTool"; // 你程序的名字

    /**
     * 检查是否已经设置开机自启
     */
    public static boolean isAutoStartEnabled() {
        try {
            Process process = Runtime.getRuntime().exec("reg query " + REG_PATH + " /v " + APP_NAME);
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
            String line;
            while ((line = reader.readLine()) != null) {
                if (line.contains(APP_NAME)) {
                    return true; // 找到启动项
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false; // 未找到
    }

    public static void main(String[] args) {
        if (isAutoStartEnabled()) {
            System.out.println("✅ 已配置开机自启");
        } else {
            System.out.println("❌ 未配置开机自启");
        }
    }
}
